using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Web.Caching;
using System.Xml;
using System.Collections;
using System.Collections.ObjectModel;

namespace _18miljard.Db
{
	internal class DbCache
	{
		internal static QueryBuilder GetQueryBuilder(string queryName)
		{
			string cacheName = "query_" + queryName;

			QueryBuilder queryBuilder = DbCache.Cache[cacheName] as QueryBuilder;

			if (queryBuilder == null)
			{
				queryBuilder = new QueryBuilder(queryName);

				CacheDependency dependency = new CacheDependency(HttpContext.Current.Server.MapPath("/App_Data/DBQueries.xml"));

				DbCache.Cache.Insert(cacheName, queryBuilder, dependency);
			}

			return queryBuilder;
		}

		private static Cache Cache
		{
			get { return HttpContext.Current.Cache; }
		}
	}
}
